package edu.ucsc.gameAI.conditions;

import pacman.game.Constants.GHOST;
import pacman.game.Game;
import edu.ucsc.gameAI.ICondition;
import edu.ucsc.gameAI.PacmanConstants;

public class DangerousGhostNearby implements ICondition {

	@Override
	public boolean test(Game game) {

		int pacmanNode = game.getPacmanCurrentNodeIndex();

		for (GHOST ghost : GHOST.values()) {
			
			if(game.getGhostLairTime(ghost) > 0 || game.isGhostEdible(ghost))
				continue;
			
			int ghostIndex = game.getGhostCurrentNodeIndex(ghost);

			if (game.getShortestPathDistance(pacmanNode, ghostIndex) < PacmanConstants.safeDistance || 
					game.getEuclideanDistance(game.getPacmanCurrentNodeIndex(), ghostIndex) < PacmanConstants.euclidianSafeDistance) {
				return true;
			}
		}
	
		return false;
	}

}
